<template>
  <div>
    <h1>Contavts</h1>
    <ul>
      <li>
        <router-link to="/contacts/allcintacts">AllCintacts</router-link>
      </li>
      <li>
        <router-link to="/contacts/alice">Alice</router-link>
      </li>
      <li>
        <router-link to="/contacts/bob">Bob</router-link>
      </li>
    </ul>
    <button @click="btn">随机显示</button>
    <hr />
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      res: "",
      list: ["/contacts/allcintacts", "/contacts/alice", "/contacts/bob"],
    };
  },
  methods: {
    btn() {
      let i = Math.floor(Math.random() * 3);
      this.res = this.list[i];
      console.log(this.res);
      this.$router.push({
        path: this.res,
      });
    },
  },
};
</script>

<style>
.router-link-exact-active {
  color: red;
}
</style>